package com.itheima.controller;

import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;
import com.itheima.entity.Result;
import com.itheima.pojo.CheckItem;
import com.itheima.service.CheckItemService;
import org.omg.PortableInterceptor.INACTIVE;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/checkitem")
public class CheckItemController {

    @Autowired
    private CheckItemService checkItemService;


    //分页条件查询
    @PostMapping("/findPage.do")
    public PageResult findPage(@RequestBody QueryPageBean queryPageBean){
        PageResult result = checkItemService.findPage(queryPageBean);
        return result;
    }
    //添加
    @PostMapping("/add.do")
    public Result add(@RequestBody CheckItem checkItem){
        Result result = checkItemService.add(checkItem);
        return result;
    }
    //删除检查项
    @GetMapping("/delete.do")
    public Result delete(Integer id){
        Result result = checkItemService.delete(id);
        return result;
    }
    //编辑回显检查项
    @GetMapping("/findById.do")
    public Result findById(Integer id){
        Result result = checkItemService.findById(id);
        return result;
    }
    //编辑保存检查项
    @PostMapping("/edit.do")
    public Result update(@RequestBody CheckItem checkItem){
        Result result = checkItemService.update(checkItem);
        return result;
    }
    //查询所有检查项
    @GetMapping("/findAll.do")
    public Result findAll(){
        Result result = checkItemService.findAll();
        return result;
    }
}
